Repository navigation
fix(fleet-dispatch): refuse invalid or truncated response framing (#8433) - #8434
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 20 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8433.
Problem
read_responseinpkgs/fleet/crates/fleet-dispatch/src/lib.rsaccepted invalid or truncated HTTP response framing: a malformedContent-Lengthwas silently treated as absent (value.parse().ok()), duplicate lengths overwrote each other,Transfer-Encodingwas accepted on acontains("chunked")test, EOF ended the body loop for every framing shape (so a body cut short of its declared length — or cut inside a chunked stream — was returned as if complete; a partial body can be valid JSON, making the truncation silent), anddechunktolerated chunks missing their CRLF terminator. This conflicts with #6582's present-but-invalid refusal contract.Change
Strict framing, validated where it is read:
chunked; anything else (includinggzip, chunked) is refused as unsupported.Framing(length / chunked / close-delimited). EOF before a declared length is met, or anywhere inside a chunked stream (including its trailer section), is a truncation transport error naming the framing and the byte counts. Unframed bodies still run to connection close.parse_chunked) distinguishes complete / incomplete / malformed: non-hex size lines and chunks missing their CRLF terminator are errors, never silent stops. The fleet(dispatch): dechunked_len does unchecked arithmetic on the peer-declared chunk size — overflow panics in debug, wraps in release #6512 checked-arithmetic discipline is preserved (peer-declared sizes are checked before any slicing or allocation; the 64 MiB body bound still applies and the decoded body never exceeds the wire bytes).dechunk/dechunked_lenare now wrappers over the strict parser.Verification
cargo test -p fleet-dispatch— 16 passed, 0 failed, including 5 new tests: loopback (TcpListener) round-trips for length/chunked-with-trailer/agreeing-duplicate/unframed bodies; refusal of malformed, conflicting, and CL+TE framings and unsupported codings; refusal of truncation after valid JSON bytes and of mid-chunk/mid-size-line cuts; refusal of malformed chunk sizes and missing CRLF terminators; trailer-section completeness pins. The pre-existing fleet(dispatch): dechunked_len does unchecked arithmetic on the peer-declared chunk size — overflow panics in debug, wraps in release #6512 huge-chunk-size pins still pass.cargo fmt -p fleet-dispatchapplied.Queue task 14827 (repo-health-code-pilot, lane code-h) — triaged inline and fixed in the same claim.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.